//
// Created by enemy1205 on 2021/9/4.
//
#include "CommandParser.h"

using namespace std;

CommandParser::CommandParser(int argc, char *argv[]) {
    this->keys = "{ help      |       |打印帮助信息 }"
                 "{ input     |       |测试视频的路径}"
                 "{ time      |       |计算运行时间 }"
                 "{ show      |       |显示测试图像、视频 }";
    this->cmdParser = new cv::CommandLineParser(argc, argv, keys);
    // 打印帮助信息
    if (this->cmdParser->has("help")) {
        this->cmdParser->printMessage();
        this->clear();
        exit(0);
    }
}

void CommandParser::Init(int argc, char *argv[]) {
    this->keys = "{ help      |       |打印帮助信息 }"
                 "{ input     |       |测试视频的路径}"
                 "{ time      |       |计算运行时间 }"
                 "{ debug     |       |打印识别未通过的限制条件 }"
                 "{ show      |       |显示测试图像、视频 }";
    this->cmdParser = new cv::CommandLineParser(argc, argv, keys);
    // 打印帮助信息
    if (this->cmdParser->has("help")) {
        this->cmdParser->printMessage();
        this->clear();
        exit(0);
    }
//    if (this->cmdParser->has("debug")) {
//    }
}

CommandParser::~CommandParser() {
    this->clear();
}

void CommandParser::clear() {
    // 清空命令行参数对象
    if (this->cmdParser != nullptr) {
//        delete this->cmdParser;
        this->cmdParser = nullptr;
    }
}